package com.shycloud.mido.member.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shycloud.mido.common.core.util.R;
import com.shycloud.mido.member.api.vo.MidoOrgVO;
import com.shycloud.mido.member.api.vo.MidoUserDataVO;
import com.shycloud.mido.member.api.vo.OptOperatorOldVO;
import com.shycloud.mido.member.service.MemberServiceV2;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 咪哆数据 controller
 *
 * @author nianhua.jiang
 * @version v1.0.0
 * @Date 2021/5/13 9:39
 * @blame Android Team
 * @see com.shycloud.mido.member.controller
 */

@RestController
@AllArgsConstructor
@Api(tags = "咪哆数据")
@RequestMapping("/mido/data")
@ApiIgnore
public class MidoDataController {

	/** 用户模块 service */
	private MemberServiceV2 memberServiceV2;

	@GetMapping("getUser")
	@ApiOperation("mido 用户信息查询列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "current", value = "当前页", paramType = "query", dataType = "int", required = true),
			@ApiImplicitParam(name = "size", value = "每页显示条数", paramType = "query", dataType = "int", required = true),
			@ApiImplicitParam(name = "username", value = "账号", paramType = "query", dataType = "string", required = true)
	})
	public R<IPage<MidoUserDataVO>> getUser(Integer current, Integer size, String username) {
		return new R(memberServiceV2.getMidoUser(new Page(current, size), username));
	}

	@GetMapping("getOrg")
	@ApiOperation("mido 机构信息查询列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "current", value = "当前页", paramType = "query", dataType = "int", required = true),
			@ApiImplicitParam(name = "size", value = "每页显示条数", paramType = "query", dataType = "int", required = true),
			@ApiImplicitParam(name = "code", value = "机构码", paramType = "query", dataType = "string", required = true)
	})
	public R<IPage<MidoOrgVO>> getOrg(Integer current, Integer size, String code) {
		return new R(memberServiceV2.getMidoOrgPage(new Page(current, size), code));
	}

	@GetMapping("getOpt")
	@ApiOperation("mido 运营商信息查询列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "current", value = "当前页", paramType = "query", dataType = "int", required = true),
			@ApiImplicitParam(name = "size", value = "每页显示条数", paramType = "query", dataType = "int", required = true),
			@ApiImplicitParam(name = "name", value = "代理商名称", paramType = "query", dataType = "string", required = true),
			@ApiImplicitParam(name = "username", value = "代理商账号", paramType = "query", dataType = "string", required = true)
	})
	public R<IPage<OptOperatorOldVO>> getOpt(String name, Integer current, Integer size, String phone) {
		// 分页参数
		Page page = new Page(current, size);
		return new R(memberServiceV2.getOpt(page, name, phone));
	}

	/**
	 * 获取运营商下属机构列表
	 * @param optId
	 * @return
	 */
	@GetMapping("getOrgByOptId")
	public R getOrgByOptId(String optId,String word) {
		return new R(memberServiceV2.getOrgList(optId,word));
	}

}